from sqlalchemy.orm import Mapped,relationship
from app.extensions import Base,INT_PK,STR_NOTNULL_UNIQUE_20

class Clas(Base):
    __tablename__ = "clases"
    id: Mapped[INT_PK]
    name: Mapped[STR_NOTNULL_UNIQUE_20]

    studentList: Mapped[list["Student"]] = relationship(
        "Student", back_populates="clas", cascade="all, delete-orphan"
    )

    def __repr__(self):
        return f"<Clas id:{self.id} name:{self.name}"

if __name__ == '__main__':
    from app.extensions import engine
    Base.metadata.create_all(engine)
    print('班级表创建成功')